diff options
author | Dmitry Petrashko <dark@d-d.me> | 2014-04-15 13:42:45 +0200 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2014-04-15 13:42:45 +0200 |
commit | fae2c3f8e646fabedb633aea2f42405f556af602 (patch) | |
tree | c60b03c6f63d3be0424b883a96d9a8a49e8bbc77 /src/dotty/tools/dotc/core | |
parent | 732a690ad2ef78450f6b8852b0f1f0ba892b392d (diff) | |
parent | d3adfd7f40708899aa033ea1e5c56d468ff9495c (diff) | |
download | dotty-fae2c3f8e646fabedb633aea2f42405f556af602.tar.gz dotty-fae2c3f8e646fabedb633aea2f42405f556af602.tar.bz2 dotty-fae2c3f8e646fabedb633aea2f42405f556af602.zip |
Merge pull request #122 from dotty-staging/transform/nullarify
Transform/nullarify
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/DenotTransformers.scala | 16 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 16 |
4 files changed, 32 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 53e8b4d2c..f1c69027e 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -341,6 +341,8 @@ class Definitions { lazy val AbstractFunctionClass = mkArityArray("scala.runtime.AbstractFunction", MaxFunctionArity, 0) lazy val FunctionClass = mkArityArray("scala.Function", MaxFunctionArity, 0) + lazy val Function0_apply = FunctionClass(0).requiredMethod(nme.apply) + lazy val TupleClass = mkArityArray("scala.Tuple", MaxTupleArity, 2) lazy val ProductNClass = mkArityArray("scala.Product", MaxTupleArity, 2) @@ -357,6 +359,7 @@ class Definitions { lazy val asInstanceOfMethods = Set[Symbol](Any_asInstanceOf, Object_asInstanceOf) lazy val isInstanceOfMethods = Set[Symbol](Any_isInstanceOf, Object_isInstanceOf) + lazy val typeTestsOrCasts = asInstanceOfMethods ++ isInstanceOfMethods lazy val RootImports = List[Symbol](JavaLangPackageVal, ScalaPackageVal, ScalaPredefModule, DottyPredefModule) @@ -440,7 +443,7 @@ class Definitions { LongClass, FloatClass, DoubleClass) - + lazy val ScalaValueClasses: collection.Set[Symbol] = ScalaNumericValueClasses + UnitClass + BooleanClass lazy val ScalaBoxedClasses = ScalaValueClasses map boxedClass diff --git a/src/dotty/tools/dotc/core/DenotTransformers.scala b/src/dotty/tools/dotc/core/DenotTransformers.scala index e1ee355d8..6daa028fc 100644 --- a/src/dotty/tools/dotc/core/DenotTransformers.scala +++ b/src/dotty/tools/dotc/core/DenotTransformers.scala @@ -5,6 +5,7 @@ import Periods._ import SymDenotations._ import Contexts._ import Types._ +import Symbols._ import Denotations._ import Phases._ import java.lang.AssertionError @@ -30,4 +31,19 @@ object DenotTransformers { /** The transformation method */ def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation } + + trait InfoTransformer extends DenotTransformer { + + def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type + + /** The transformation method */ + def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = { + val info1 = transformInfo(ref.info, ref.symbol) + if (info1 eq ref.info) ref + else ref match { + case ref: SymDenotation => ref.copySymDenotation(info = info1) + case _ => ref.derivedSingleDenotation(ref.symbol, info1) + } + } + } } diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 63b94efbd..e5f5e6f87 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -512,7 +512,7 @@ object Denotations { def current(implicit ctx: Context): SingleDenotation = { val currentPeriod = ctx.period val valid = myValidFor - assert(valid.code > 0, s"negative period $valid: ${valid.code}") + assert(valid.code > 0) if (valid.runId != currentPeriod.runId) bringForward.current else { diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index c348e246c..66f027915 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -352,6 +352,12 @@ object Types { goThis(tp) case tp: TypeRef => tp.denot.findMember(name, pre, excluded) + case tp: TermRef => + go (tp.underlying match { + case mt: MethodType + if mt.paramTypes.isEmpty && (tp.symbol is Stable) => mt.resultType + case tp1 => tp1 + }) case tp: TypeProxy => go(tp.underlying) case tp: ClassInfo => @@ -449,7 +455,7 @@ object Types { final def implicitMembers(implicit ctx: Context): List[TermRef] = track("implicitMembers") { memberDenots(implicitFilter, (name, buf) => buf ++= member(name).altsWith(_ is Implicit)) - .toList.map(_.termRefWithSig) + .toList.map(d => TermRef.withSig(this, d.symbol.asTerm)) } /** The info of `sym`, seen as a member of this type. */ @@ -1101,14 +1107,14 @@ object Types { private def withSig(sig: Signature)(implicit ctx: Context): NamedType = TermRef.withSig(prefix, name.asTermName, sig) - protected def loadDenot(implicit ctx: Context) = { + protected def loadDenot(implicit ctx: Context): Denotation = { val d = if (name.isInheritedName) prefix.nonPrivateMember(name.revertInherited) else prefix.member(name) - if (d.exists || ctx.phaseId == FirstPhaseId) + if (d.exists || ctx.phaseId == FirstPhaseId || !lastDenotation.isInstanceOf[SymDenotation]) d else {// name has changed; try load in earlier phase and make current - val d = denot(ctx.withPhase(ctx.phaseId - 1)).current + val d = loadDenot(ctx.withPhase(ctx.phaseId - 1)).current if (d.exists) d else throw new Error(s"failure to reload $this") } @@ -1311,7 +1317,7 @@ object Types { if (prefix eq NoPrefix) withNonMemberSym(prefix, name, sym) else { if (sym.defRunId != NoRunId && sym.isCompleted) withSig(prefix, name, sym.signature) - else apply(prefix, name) + else apply(prefix, name) } withSym (sym, Signature.NotAMethod) def withSig(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef = |