Skip to content

Commit ab897b6

Browse files
committed
Merge branch 'master' into GenASM
2 parents 073534b + 3da5075 commit ab897b6

File tree

10 files changed

+157
-9
lines changed

10 files changed

+157
-9
lines changed

src/compiler/scala/reflect/internal/Types.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4579,7 +4579,7 @@ trait Types extends api.Types { self: SymbolTable =>
45794579
var rebind0 = pre.findMember(sym.name, BRIDGE, 0, true)
45804580
if (rebind0 == NoSymbol) {
45814581
if (sym.isAliasType) throw missingAliasException
4582-
if (settings.debug.value) println(pre+"."+sym+" does no longer exist, phase = "+phase)
4582+
debugwarn(pre+"."+sym+" does no longer exist, phase = "+phase)
45834583
throw new MissingTypeControl // For build manager and presentation compiler purposes
45844584
//assert(false, pre+"."+sym+" does no longer exist, phase = "+phase)
45854585
}
@@ -4635,7 +4635,7 @@ trait Types extends api.Types { self: SymbolTable =>
46354635
if ((pre1 eq pre) && (sym1 eq sym) && (args1 eq args)/* && sym.isExternal*/) {
46364636
tp
46374637
} else if (sym1 == NoSymbol) {
4638-
if (settings.debug.value) println("adapt fail: "+pre+" "+pre1+" "+sym)
4638+
debugwarn("adapt fail: "+pre+" "+pre1+" "+sym)
46394639
tp
46404640
} else {
46414641
copyTypeRef(tp, pre1, sym1, args1)

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
863863

864864
def genField(f: IField) {
865865
debuglog("Adding field: " + f.symbol.fullName)
866+
866867
val jfield = jclass.addNewField(
867868
javaFlags(f.symbol) | javaFieldFlags(f.symbol),
868869
javaName(f.symbol),
@@ -1917,6 +1918,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
19171918
((sym.rawflags & (Flags.FINAL | Flags.MODULE)) != 0)
19181919
&& !sym.enclClass.isInterface
19191920
&& !sym.isClassConstructor
1921+
&& (sym.isLazy || sym.isPrivate || !sym.isMutable) // fix for SI-3569, is it sufficient?
19201922
)
19211923

19221924
mkFlags(

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,6 @@ trait ContextErrors {
726726
// we have to set the type of tree to ErrorType only in the very last
727727
// fallback action that is done in the inference (tracking it manually is error prone).
728728
// This avoids entering infinite loop in doTypeApply.
729-
// TODO: maybe we should do the same thing with inferExprAlternative.
730729
if (implicitly[Context].reportErrors) setError(tree)
731730
}
732731

@@ -736,6 +735,8 @@ trait ContextErrors {
736735
"argument types " + argtpes.mkString("(", ",", ")") +
737736
(if (pt == WildcardType) "" else " and expected result type " + pt)
738737
val (pos, msg) = ambiguousErrorMsgPos(tree.pos, pre, best, firstCompeting, msg0)
738+
// discover last attempt in a similar way as for NoBestMethodAlternativeError
739+
if (implicitly[Context].ambiguousErrors) setError(tree)
739740
issueAmbiguousTypeError(pre, best, firstCompeting, AmbiguousTypeError(tree, pos, msg))
740741
}
741742

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,14 @@ trait Contexts { self: Analyzer =>
312312
unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
313313

314314
def issue(err: AbsTypeError) {
315-
if (settings.debug.value) println("issue error: " + err.errMsg)
315+
debugwarn("issue error: " + err.errMsg)
316316
if (reportErrors) unitError(err.errPos, addDiagString(err.errMsg))
317317
else if (bufferErrors) { buffer += err }
318318
else throw new TypeError(err.errPos, err.errMsg)
319319
}
320320

321321
def issueAmbiguousError(pre: Type, sym1: Symbol, sym2: Symbol, err: AbsTypeError) {
322+
debugwarn("issue ambiguous error: " + err.errMsg)
322323
if (ambiguousErrors) {
323324
if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous)
324325
unitError(err.errPos, err.errMsg)
@@ -327,6 +328,7 @@ trait Contexts { self: Analyzer =>
327328
}
328329

329330
def issueAmbiguousError(err: AbsTypeError) {
331+
debugwarn("issue ambiguous error: " + err.errMsg)
330332
if (ambiguousErrors)
331333
unitError(err.errPos, addDiagString(err.errMsg))
332334
else if (bufferErrors) { buffer += err }

src/compiler/scala/tools/nsc/typechecker/Infer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,14 +1493,12 @@ trait Infer {
14931493
if (improves(alt, best)) alt else best)
14941494
val competing = applicable.dropWhile(alt => best == alt || improves(best, alt))
14951495
if (best == NoSymbol) {
1496-
if (pt == WildcardType)
1497-
NoBestMethodAlternativeError(tree, argtpes, pt)
1498-
else
1499-
inferMethodAlternative(tree, undetparams, argtpes, WildcardType)
1496+
if (pt == WildcardType) NoBestMethodAlternativeError(tree, argtpes, pt)
1497+
else inferMethodAlternative(tree, undetparams, argtpes, WildcardType)
15001498
} else if (!competing.isEmpty) {
15011499
if (!(argtpes exists (_.isErroneous)) && !pt.isErroneous)
15021500
AmbiguousMethodAlternativeError(tree, pre, best, competing.head, argtpes, pt)
1503-
setError(tree)
1501+
else setError(tree)
15041502
()
15051503
} else {
15061504
// checkNotShadowed(tree.pos, pre, best, applicable)

test/files/neg/t5554.check

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
t5554.scala:14: error: ambiguous reference to overloaded definition,
2+
both method apply in object Foo1 of type (x: Int)(implicit z: String)String
3+
and method apply in object Foo1 of type (x: Int)Base[T]
4+
match argument types (Int)
5+
def test1[T]: Int = Foo1[T](1)
6+
^
7+
t5554.scala:16: error: ambiguous reference to overloaded definition,
8+
both method apply in object Foo1 of type (x: Int)(implicit z: String)String
9+
and method apply in object Foo1 of type (x: Int)Base[T]
10+
match argument types (Int)
11+
def test3[T]: String = Foo1[T](1)
12+
^
13+
t5554.scala:17: error: ambiguous reference to overloaded definition,
14+
both method apply in object Foo1 of type (x: Int)(implicit z: String)String
15+
and method apply in object Foo1 of type (x: Int)Base[T]
16+
match argument types (Int)
17+
def test4[T] = Foo1[T](1)
18+
^
19+
t5554.scala:22: error: ambiguous reference to overloaded definition,
20+
both method apply in object Foo1 of type (x: Int)(implicit z: String)String
21+
and method apply in object Foo1 of type (x: Int)Base[T]
22+
match argument types (Int)
23+
def test5[T]: Int = Foo1[T](1)
24+
^
25+
t5554.scala:25: error: ambiguous reference to overloaded definition,
26+
both method apply in object Foo1 of type (x: Int)(implicit z: String)String
27+
and method apply in object Foo1 of type (x: Int)Base[T]
28+
match argument types (Int)
29+
def test8[T] = Foo1[T](1)
30+
^
31+
t5554.scala:29: error: ambiguous reference to overloaded definition,
32+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
33+
and method apply in object Foo2 of type (x: Int)Base[T]
34+
match argument types (Int)
35+
def test9[T]: String = Foo2[T](1)
36+
^
37+
t5554.scala:30: error: ambiguous reference to overloaded definition,
38+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
39+
and method apply in object Foo2 of type (x: Int)Base[T]
40+
match argument types (Int) and expected result type Base[T]
41+
def test10[T]: Base[T] = Foo2[T](1)
42+
^
43+
t5554.scala:31: error: ambiguous reference to overloaded definition,
44+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
45+
and method apply in object Foo2 of type (x: Int)Base[T]
46+
match argument types (Int)
47+
def test11[T] = Foo2[T](1)
48+
^
49+
t5554.scala:36: error: ambiguous reference to overloaded definition,
50+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
51+
and method apply in object Foo2 of type (x: Int)Base[T]
52+
match argument types (Int)
53+
def test12[T]: String = Foo2[T](1)
54+
^
55+
t5554.scala:37: error: ambiguous reference to overloaded definition,
56+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
57+
and method apply in object Foo2 of type (x: Int)Base[T]
58+
match argument types (Int) and expected result type Base[T]
59+
def test13[T]: Base[T] = Foo2[T](1)
60+
^
61+
t5554.scala:38: error: ambiguous reference to overloaded definition,
62+
both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T]
63+
and method apply in object Foo2 of type (x: Int)Base[T]
64+
match argument types (Int)
65+
def test14[T] = Foo2[T](1)
66+
^
67+
11 errors found

test/files/neg/t5554.scala

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
class Base[T]
2+
3+
object Foo1 {
4+
def apply[T](x: Int): Base[T] = new Base[T]
5+
def apply[T](x: Int)(implicit z: String): String = z
6+
}
7+
8+
object Foo2 {
9+
def apply[T](x: Int): Base[T] = new Base[T]
10+
def apply[T](x: Int)(implicit z: String): Base[T] = new Base[T]
11+
}
12+
13+
object Test1 {
14+
def test1[T]: Int = Foo1[T](1)
15+
def test2[T]: Base[T] = Foo1[T](1)
16+
def test3[T]: String = Foo1[T](1)
17+
def test4[T] = Foo1[T](1)
18+
}
19+
20+
object Test2 {
21+
implicit val v: String = "foo"
22+
def test5[T]: Int = Foo1[T](1)
23+
def test6[T]: Base[T] = Foo1[T](1)
24+
def test7[T]: String = Foo1[T](1)
25+
def test8[T] = Foo1[T](1)
26+
}
27+
28+
object Test3 {
29+
def test9[T]: String = Foo2[T](1)
30+
def test10[T]: Base[T] = Foo2[T](1)
31+
def test11[T] = Foo2[T](1)
32+
}
33+
34+
object Test4 {
35+
implicit val v: String = "foo"
36+
def test12[T]: String = Foo2[T](1)
37+
def test13[T]: Base[T] = Foo2[T](1)
38+
def test14[T] = Foo2[T](1)
39+
}

test/files/run/t3569.check

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
1
2+
private final int Test$X.x2
3+
private final int Test$X.x3
4+
private final int Test$X.x5
5+
private final int Test$X.x6
6+
private final int Test$X.x7
7+
private int Test$X.x4
8+
private volatile int Test$X.bitmap$priv$0
9+
public int Test$X.x
10+
public volatile int Test$X.bitmap$0
11+
private int Test$Y.z1
12+
public int Test$Y.x
13+
public int Test$Y.y
14+
public int Test$Y.z2

test/files/run/t3569.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Yinline

test/files/run/t3569.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object Test {
2+
lazy val lv = scala.util.Random.nextInt()
3+
4+
class X(final var x: Int) {
5+
final private[this] var x2: Int = 0
6+
final var x3: Int = 0
7+
private[this] var x4: Int = 0
8+
final private[this] var x5: Int = 0
9+
final lazy val x6: Int = 0
10+
final private[this] lazy val x7: Int = 0
11+
}
12+
case class Y(final var x: Int, final private var y: Int, var z1: Int, private var z2: Int) { }
13+
14+
def f = new X(0).x += 1
15+
def main(args: Array[String]) {
16+
f
17+
val s = new X(0)
18+
s.x += 1
19+
println(s.x)
20+
21+
(classOf[X].getDeclaredFields map ("" + _)).sorted foreach println
22+
(classOf[Y].getDeclaredFields map ("" + _)).sorted foreach println
23+
}
24+
}

0 commit comments

Comments
 (0)