aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/common4
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--src/dotty/tools/dotc/transform/Erasure.scala18
-rw-r--r--src/dotty/tools/dotc/transform/LambdaLift.scala2
-rw-r--r--src/dotty/tools/dotc/transform/TraitConstructors.scala3
-rw-r--r--tests/run/innerInObject.check2
-rw-r--r--tests/run/innerInObject.scala24
7 files changed, 47 insertions, 8 deletions
diff --git a/scripts/common b/scripts/common
index 9ebfb8197..50b13f8d7 100755
--- a/scripts/common
+++ b/scripts/common
@@ -11,4 +11,6 @@ update() {
git reset --hard
}
-sbtArgs="-Ddotty.travis.build=yes -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13"
+export LC_ALL=en_US.UTF-8
+
+sbtArgs="-Ddotty.travis.build=yes -Dfile.encoding=UTF-8 -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13"
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 5e37324a0..c6264b817 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -315,7 +315,7 @@ object SymDenotations {
encl = encl.owner
sep += "~"
}
- if (owner.is(ModuleClass) && sep == "$") sep = "" // duplicate scalac's behavior: don't write a double '$$' for module class members.
+ if (owner.is(ModuleClass, butNot = Package) && sep == "$") sep = "" // duplicate scalac's behavior: don't write a double '$$' for module class members.
val fn = encl.fullNameSeparated(separator) ++ sep ++ name
if (isType) fn.toTypeName else fn.toTermName
}
diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala
index 36d75b149..749bbed93 100644
--- a/src/dotty/tools/dotc/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/transform/Erasure.scala
@@ -469,16 +469,26 @@ object Erasure extends TypeTestsCasts{
tpt = untpd.TypedSplice(TypeTree(sym.info).withPos(vdef.tpt.pos))), sym)
override def typedDefDef(ddef: untpd.DefDef, sym: Symbol)(implicit ctx: Context) = {
- val restpe = sym.info.resultType
+ var effectiveSym = sym
+ if (sym == defn.newRefArrayMethod) {
+ // newRefArray is treated specially: It's the only source-defined method
+ // that has a polymorphic type after erasure. But treating its (dummy) definition
+ // with a polymorphic type at and after erasure is an awkward special case.
+ // We therefore rewrite the method definition with a new Symbol of type
+ // (length: Int)Object
+ val MethodType(pnames, ptypes) = sym.info.resultType
+ effectiveSym = sym.copy(info = MethodType(pnames, ptypes, defn.ObjectType))
+ }
+ val restpe = effectiveSym.info.resultType
val ddef1 = untpd.cpy.DefDef(ddef)(
tparams = Nil,
- vparamss = (outer.paramDefs(sym) ::: ddef.vparamss.flatten) :: Nil,
+ vparamss = (outer.paramDefs(effectiveSym) ::: ddef.vparamss.flatten) :: Nil,
tpt = untpd.TypedSplice(TypeTree(restpe).withPos(ddef.tpt.pos)),
rhs = ddef.rhs match {
case id @ Ident(nme.WILDCARD) => untpd.TypedSplice(id.withType(restpe))
case _ => ddef.rhs
})
- super.typedDefDef(ddef1, sym)
+ super.typedDefDef(ddef1, effectiveSym)
}
/** After erasure, we may have to replace the closure method by a bridge.
@@ -600,7 +610,7 @@ object Erasure extends TypeTestsCasts{
traverse(newStats, oldStats)
}
-
+
private final val NoBridgeFlags = Flags.Accessor | Flags.Deferred | Flags.Lazy
/** Create a bridge DefDef which overrides a parent method.
diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala
index 42c6e85af..0cbbb769f 100644
--- a/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -292,7 +292,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
val encClass = local.enclosingClass
val topClass = local.topLevelClass
// member of a static object
- if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
+ if (encClass.isStatic && encClass.isContainedIn(topClass)) {
// though the second condition seems weird, it's not true for symbols which are defined in some
// weird combinations of super calls.
(encClass, EmptyFlags)
diff --git a/src/dotty/tools/dotc/transform/TraitConstructors.scala b/src/dotty/tools/dotc/transform/TraitConstructors.scala
index a98f52ca4..99ae3e187 100644
--- a/src/dotty/tools/dotc/transform/TraitConstructors.scala
+++ b/src/dotty/tools/dotc/transform/TraitConstructors.scala
@@ -23,7 +23,8 @@ class TraitConstructors extends MiniPhaseTransform with SymTransformer {
def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = {
if (sym.isPrimaryConstructor && (sym.owner is Flags.Trait))
- sym.copySymDenotation(name = nme.INITIALIZER_PREFIX ++ sym.owner.fullName)
+ // TODO: Someone needs to carefully check if name clashes are possible with this mangling scheme
+ sym.copySymDenotation(name = nme.INITIALIZER_PREFIX ++ sym.owner.fullNameSeparated("$"))
else sym
}
diff --git a/tests/run/innerInObject.check b/tests/run/innerInObject.check
new file mode 100644
index 000000000..1191247b6
--- /dev/null
+++ b/tests/run/innerInObject.check
@@ -0,0 +1,2 @@
+1
+2
diff --git a/tests/run/innerInObject.scala b/tests/run/innerInObject.scala
new file mode 100644
index 000000000..5a5ece416
--- /dev/null
+++ b/tests/run/innerInObject.scala
@@ -0,0 +1,24 @@
+object Test {
+ def foo(x: Int) = {
+ println(x)
+ }
+
+ def outer(x: Int) = {
+ def inner() = {
+ foo(x)
+ }
+ inner()
+ }
+
+ def outer2(x: Int) = {
+ def inner2() = {
+ Test.foo(x)
+ }
+ inner2()
+ }
+
+ def main(args: Array[String]): Unit = {
+ outer(1)
+ outer2(2)
+ }
+}