Skip to content

Commit 4b9c555

Browse files
authored
Merge pull request #6307 from dotty-staging/revisit-dotty-deviations
Revisit Dotty Deviations
2 parents defe9ab + dfea2bd commit 4b9c555

File tree

7 files changed

+8
-26
lines changed

7 files changed

+8
-26
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
383383

384384
val linkedClass = moduleClass.companionClass
385385
lazy val conflictingNames: Set[Name] = {
386-
// Dotty deviation: needed to add ": Symbol" because of https://github.com/lampepfl/dotty/issues/2143
387386
(linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name }).toSet
388387
}
389388
debuglog(s"Potentially conflicting names for forwarders: $conflictingNames")

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ object Symbols {
803803
*/
804804
def copy(
805805
owner: Symbol = sym.owner,
806-
name: N = (sym.name: N), // Dotty deviation: type ascription to avoid leaking private sym (only happens in unpickling), won't be needed once #1723 is fixed
806+
name: N = sym.name,
807807
flags: FlagSet = sym.flags,
808808
info: Type = sym.info,
809809
privateWithin: Symbol = sym.privateWithin,

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@ class ClassfileParser(
137137
val ifaceCount = in.nextChar
138138
var ifaces = for (i <- (0 until ifaceCount).toList) yield pool.getSuperClass(in.nextChar).typeRef
139139
// Dotty deviation: was
140-
// var ifaces = for (i <- List.range(0 until ifaceCount)) ...
140+
// var ifaces = for (i <- List.range(0, ifaceCount)) ...
141141
// This does not typecheck because the type parameter of List is now lower-bounded by Int | Char.
142142
// Consequently, no best implicit for the "Integral" evidence parameter of "range"
143-
// is found. If we treat constant subtyping specially, we might be able
144-
// to do something there. But in any case, the until should be more efficient.
143+
// is found. Previously, this worked because of weak conformance, which has been dropped.
145144

146145
if (isAnnotation) ifaces = defn.ClassfileAnnotationType :: ifaces
147146
superType :: ifaces

compiler/src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ object LambdaLift {
6464
/** A flag to indicate whether lifted owners have changed */
6565
private[this] var changedLiftedOwner: Boolean = _
6666

67-
private val ord: Ordering[Symbol] = Ordering.by((_: Symbol).id) // Dotty deviation: Type annotation needed. TODO: figure out why
67+
private val ord: Ordering[Symbol] = Ordering.by(_.id)
6868
private def newSymSet = TreeSet.empty[Symbol](ord)
6969

7070
private def symSet(f: LinkedHashMap[Symbol, SymSet], sym: Symbol): SymSet =

compiler/src/dotty/tools/dotc/transform/RestoreScopes.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ class RestoreScopes extends MiniPhase with IdentityDenotTransformer { thisPhase
4242
val pkg = cls.owner.asClass
4343

4444
pkg.enter(cls)
45-
val cinfo = cls.classInfo
4645
tree.symbol.copySymDenotation(
47-
info = cinfo.derivedClassInfo( // Dotty deviation: Cannot expand cinfo inline without a type error
46+
info = cls.classInfo.derivedClassInfo(
4847
decls = restoredDecls: Scope)).installAfter(thisPhase)
4948
tree
5049
case tree => tree

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
788788

789789
/** Subclass of Application for type checking an Apply node with typed arguments. */
790790
class ApplyToTyped(app: untpd.Apply, fun: Tree, methRef: TermRef, args: List[Tree], resultType: Type)(implicit ctx: Context)
791-
extends TypedApply[Type](app, fun, methRef, args, resultType) {
792-
// Dotty deviation: Dotc infers Untyped for the supercall. This seems to be according to the rules
793-
// (of both Scala and Dotty). Untyped is legal, and a subtype of Typed, whereas TypeApply
794-
// is invariant in the type parameter, so the minimal type should be inferred. But then typedArg does
795-
// not match the abstract method in Application and an abstract class error results.
796-
def typedArg(arg: Tree, formal: Type): TypedArg = arg
791+
extends TypedApply(app, fun, methRef, args, resultType) {
792+
def typedArg(arg: Tree, formal: Type): TypedArg = arg
797793
def treeToArg(arg: Tree): Tree = arg
798794
def typeOfArg(arg: Tree): Type = arg.tpe
799795
}

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,18 +483,7 @@ object RefChecks {
483483
val missing = clazz.thisType.abstractTermMembers.filterNot(ignoreDeferred)
484484
// Group missing members by the name of the underlying symbol,
485485
// to consolidate getters and setters.
486-
val grouped: Map[Name, Seq[SingleDenotation]] = missing groupBy (_.symbol.underlyingSymbol.name)
487-
// Dotty deviation: Added type annotation for `grouped`.
488-
// The inferred type is Map[Symbol#ThisName, Seq[SingleDenotation]]
489-
// but then the definition of isMultiple fails with an error:
490-
// RefChecks.scala:379: error: type mismatch:
491-
// found : underlying.ThisName
492-
// required: dotty.tools.dotc.core.Symbols.Symbol#ThisName
493-
//
494-
// val isMultiple = grouped.getOrElse(underlying.name(ctx), Nil).size > 1
495-
// ^
496-
// As far as I can see, the complaint is correct, even under the
497-
// old reading where Symbol#ThisName means x.ThisName forSome { val x }
486+
val grouped = missing.groupBy(_.symbol.underlyingSymbol.name)
498487

499488
val missingMethods = grouped.toList flatMap {
500489
case (name, syms) =>

0 commit comments

Comments
 (0)