aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorNicolas Stucki <nicolas.stucki@gmail.com>2017-02-01 10:04:19 +0100
committerGitHub <noreply@github.com>2017-02-01 10:04:19 +0100
commitb5185f1b4481ef61243741c7f7ed0ba8f696776b (patch)
tree7f7c18662e3e011374d1f2bbe78893e8ffac2722 /compiler/src/dotty/tools/dotc/core
parentaf7fdb32df34b352bf39f01a26653b169e0d55cf (diff)
parentf7278e16ffa8ff242b7d985803015170dbf80ce7 (diff)
downloaddotty-b5185f1b4481ef61243741c7f7ed0ba8f696776b.tar.gz
dotty-b5185f1b4481ef61243741c7f7ed0ba8f696776b.tar.bz2
dotty-b5185f1b4481ef61243741c7f7ed0ba8f696776b.zip
Merge pull request #1919 from dotty-staging/fix-#1915
Fix #1915 Synthetic function traits need NoInits flag
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Definitions.scala14
-rw-r--r--compiler/src/dotty/tools/dotc/core/Phases.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala2
3 files changed, 14 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala
index 716c9ef23..7fe6505ff 100644
--- a/compiler/src/dotty/tools/dotc/core/Definitions.scala
+++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala
@@ -133,7 +133,7 @@ class Definitions {
ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: parentTraits, decls)
}
}
- newClassSymbol(ScalaPackageClass, name, Trait, completer)
+ newClassSymbol(ScalaPackageClass, name, Trait | NoInits, completer)
}
private def newMethod(cls: ClassSymbol, name: TermName, info: Type, flags: FlagSet = EmptyFlags): TermSymbol =
@@ -770,6 +770,18 @@ class Definitions {
lazy val PhantomClasses = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass)
+ /** Classes that are known not to have an initializer irrespective of
+ * whether NoInits is set. Note: FunctionXXLClass is in this set
+ * because if it is compiled by Scala2, it does not get a NoInit flag.
+ * But since it is introduced only at erasure, there's no chance
+ * for augmentScala2Traits to do anything on a class that inherits it. So
+ * it also misses an implementation class, which means that the usual scheme
+ * of calling a superclass init in the implementation class of a Scala2
+ * trait gets screwed up. Therefore, it is mandatory that FunctionXXL
+ * is treated as a NoInit trait.
+ */
+ lazy val NoInitClasses = PhantomClasses + FunctionXXLClass
+
def isPolymorphicAfterErasure(sym: Symbol) =
(sym eq Any_isInstanceOf) || (sym eq Any_asInstanceOf)
diff --git a/compiler/src/dotty/tools/dotc/core/Phases.scala b/compiler/src/dotty/tools/dotc/core/Phases.scala
index 6a53e1b30..d217afed8 100644
--- a/compiler/src/dotty/tools/dotc/core/Phases.scala
+++ b/compiler/src/dotty/tools/dotc/core/Phases.scala
@@ -40,9 +40,6 @@ trait Phases {
def atPhaseNotLaterThan[T](limit: Phase)(op: Context => T): T =
if (!limit.exists || phase <= limit) op(this) else atPhase(limit)(op)
- def atPhaseNotLaterThanTyper[T](op: Context => T): T =
- atPhaseNotLaterThan(base.typerPhase)(op)
-
def isAfterTyper: Boolean = base.isAfterTyper(phase)
}
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index 97a82e80d..5b751ef3c 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -818,7 +818,7 @@ class ClassfileParser(
case Some(entry) =>
val outerName = entry.outerName.stripModuleClassSuffix
val owner = classSymbol(outerName)
- val result = ctx.atPhaseNotLaterThanTyper { implicit ctx =>
+ val result = ctx.atPhaseNotLaterThan(ctx.typerPhase) { implicit ctx =>
getMember(owner, innerName.toTypeName)
}
assert(result ne NoSymbol,