Skip to content

Revisit Dotty Deviations #6307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {

val linkedClass = moduleClass.companionClass
lazy val conflictingNames: Set[Name] = {
// Dotty deviation: needed to add ": Symbol" because of https://github.com/lampepfl/dotty/issues/2143
(linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name }).toSet
}
debuglog(s"Potentially conflicting names for forwarders: $conflictingNames")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ object Symbols {
*/
def copy(
owner: Symbol = sym.owner,
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
name: N = sym.name,
flags: FlagSet = sym.flags,
info: Type = sym.info,
privateWithin: Symbol = sym.privateWithin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ class ClassfileParser(
val ifaceCount = in.nextChar
var ifaces = for (i <- (0 until ifaceCount).toList) yield pool.getSuperClass(in.nextChar).typeRef
// Dotty deviation: was
// var ifaces = for (i <- List.range(0 until ifaceCount)) ...
// var ifaces = for (i <- List.range(0, ifaceCount)) ...
// This does not typecheck because the type parameter of List is now lower-bounded by Int | Char.
// Consequently, no best implicit for the "Integral" evidence parameter of "range"
// is found. If we treat constant subtyping specially, we might be able
// to do something there. But in any case, the until should be more efficient.
// is found. Previously, this worked because of weak conformance, which has been dropped.

if (isAnnotation) ifaces = defn.ClassfileAnnotationType :: ifaces
superType :: ifaces
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object LambdaLift {
/** A flag to indicate whether lifted owners have changed */
private[this] var changedLiftedOwner: Boolean = _

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

private def symSet(f: LinkedHashMap[Symbol, SymSet], sym: Symbol): SymSet =
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/transform/RestoreScopes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class RestoreScopes extends MiniPhase with IdentityDenotTransformer { thisPhase
val pkg = cls.owner.asClass

pkg.enter(cls)
val cinfo = cls.classInfo
tree.symbol.copySymDenotation(
info = cinfo.derivedClassInfo( // Dotty deviation: Cannot expand cinfo inline without a type error
info = cls.classInfo.derivedClassInfo(
decls = restoredDecls: Scope)).installAfter(thisPhase)
tree
case tree => tree
Expand Down
8 changes: 2 additions & 6 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -788,12 +788,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>

/** Subclass of Application for type checking an Apply node with typed arguments. */
class ApplyToTyped(app: untpd.Apply, fun: Tree, methRef: TermRef, args: List[Tree], resultType: Type)(implicit ctx: Context)
extends TypedApply[Type](app, fun, methRef, args, resultType) {
// Dotty deviation: Dotc infers Untyped for the supercall. This seems to be according to the rules
// (of both Scala and Dotty). Untyped is legal, and a subtype of Typed, whereas TypeApply
// is invariant in the type parameter, so the minimal type should be inferred. But then typedArg does
// not match the abstract method in Application and an abstract class error results.
def typedArg(arg: Tree, formal: Type): TypedArg = arg
extends TypedApply(app, fun, methRef, args, resultType) {
def typedArg(arg: Tree, formal: Type): TypedArg = arg
def treeToArg(arg: Tree): Tree = arg
def typeOfArg(arg: Tree): Type = arg.tpe
}
Expand Down
13 changes: 1 addition & 12 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,7 @@ object RefChecks {
val missing = clazz.thisType.abstractTermMembers.filterNot(ignoreDeferred)
// Group missing members by the name of the underlying symbol,
// to consolidate getters and setters.
val grouped: Map[Name, Seq[SingleDenotation]] = missing groupBy (_.symbol.underlyingSymbol.name)
// Dotty deviation: Added type annotation for `grouped`.
// The inferred type is Map[Symbol#ThisName, Seq[SingleDenotation]]
// but then the definition of isMultiple fails with an error:
// RefChecks.scala:379: error: type mismatch:
// found : underlying.ThisName
// required: dotty.tools.dotc.core.Symbols.Symbol#ThisName
//
// val isMultiple = grouped.getOrElse(underlying.name(ctx), Nil).size > 1
// ^
// As far as I can see, the complaint is correct, even under the
// old reading where Symbol#ThisName means x.ThisName forSome { val x }
val grouped = missing.groupBy(_.symbol.underlyingSymbol.name)

val missingMethods = grouped.toList flatMap {
case (name, syms) =>
Expand Down