Skip to content

Commit 502b9f0

Browse files
committed
Merge pull request scala#2878 from JamesIry/2.10.3
Merge 2.10.2 into 2.10.3
2 parents 7b351dc + 682cf97 commit 502b9f0

File tree

18 files changed

+100
-30
lines changed

18 files changed

+100
-30
lines changed

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ abstract class ClassfileParser {
4444

4545
def srcfile = srcfile0
4646

47-
private def currentIsTopLevel = !(currentClass.decodedName containsChar '$')
48-
4947
private object unpickler extends scala.reflect.internal.pickling.UnPickler {
5048
val global: ClassfileParser.this.global.type = ClassfileParser.this.global
5149
}
@@ -515,8 +513,10 @@ abstract class ClassfileParser {
515513
}
516514
}
517515

518-
val c = if (currentIsTopLevel) pool.getClassSymbol(nameIdx) else clazz
519-
if (currentIsTopLevel) {
516+
val isTopLevel = !(currentClass containsChar '$') // Java class name; *don't* try to to use Scala name decoding (SI-7532)
517+
518+
val c = if (isTopLevel) pool.getClassSymbol(nameIdx) else clazz
519+
if (isTopLevel) {
520520
if (c != clazz) {
521521
if ((clazz eq NoSymbol) && (c ne NoSymbol)) clazz = c
522522
else mismatchError(c)

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -997,22 +997,11 @@ trait Implicits {
997997
if (settings.Xdivergence211.value) DivergingImplicitExpansionError(tree, pt, DivergentImplicitRecovery.sym)(context)
998998
else throw DivergentImplicit
999999
}
1000-
else if (invalidImplicits.nonEmpty) {
1001-
val sym = invalidImplicits.head
1002-
// We don't even dare look if errors are being buffered
1003-
// !sym.hasFlag(LOCKED) is a hail mary between SI-2206 and SI-7486
1004-
def isSensibleAddendum = !sym.hasFlag(LOCKED) && (pt match {
1005-
case Function1(_, out) => out <:< sym.tpe.finalResultType
1006-
case _ => pt <:< sym.tpe.finalResultType
1007-
})
1008-
// Don't pitch in with this theory unless it looks plausible that the
1009-
// implicit would have helped
1000+
1001+
if (invalidImplicits.nonEmpty)
10101002
setAddendum(pos, () =>
1011-
if (isSensibleAddendum)
1012-
s"\n Note: implicit $sym is not applicable here because it comes after the application point and it lacks an explicit result type"
1013-
else ""
1003+
s"\n Note: implicit ${invalidImplicits.head} is not applicable here because it comes after the application point and it lacks an explicit result type"
10141004
)
1015-
}
10161005
}
10171006

10181007
best

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,13 @@ trait NamesDefaults { self: Analyzer =>
284284
case Typed(expr, Ident(tpnme.WILDCARD_STAR)) => expr.tpe
285285
case _ => seqType(arg.tpe)
286286
}
287-
else
288-
// Note stabilizing can lead to a non-conformant argument when existentials are involved, e.g. neg/t3507-old.scala, hence the filter.
289-
// We have to deconst or types inferred from literal arguments will be Constant(_), e.g. pos/z1730.scala.
290-
gen.stableTypeFor(arg).filter(_ <:< paramTpe).getOrElse(arg.tpe).deconst
291-
)
287+
else {
288+
// TODO In 83c9c764b, we tried to a stable type here to fix SI-7234. But the resulting TypeTree over a
289+
// singleton type without an original TypeTree fails to retypecheck after a resetLocalAttrs (SI-7516),
290+
// which is important for (at least) macros.
291+
arg.tpe
292+
}
293+
).widen // have to widen or types inferred from literal defaults will be singletons
292294
val s = context.owner.newValue(unit.freshTermName("x$"), arg.pos) setInfo {
293295
val tp = if (byName) functionType(Nil, argTpe) else argTpe
294296
uncheckedBounds(tp)
@@ -334,9 +336,12 @@ trait NamesDefaults { self: Analyzer =>
334336
// type the application without names; put the arguments in definition-site order
335337
val typedApp = doTypedApply(tree, funOnly, reorderArgs(namelessArgs, argPos), mode, pt)
336338
typedApp match {
337-
// Extract the typed arguments, restore the call-site evaluation order (using
338-
// ValDef's in the block), change the arguments to these local values.
339-
case Apply(expr, typedArgs) if !(typedApp :: typedArgs).exists(_.isErrorTyped) => // bail out with erroneous args, see SI-7238
339+
case Apply(expr, typedArgs) if (typedApp :: typedArgs).exists(_.isErrorTyped) =>
340+
setError(tree) // bail out with and erroneous Apply *or* erroneous arguments, see SI-7238, SI-7509
341+
case Apply(expr, typedArgs) =>
342+
// Extract the typed arguments, restore the call-site evaluation order (using
343+
// ValDef's in the block), change the arguments to these local values.
344+
340345
// typedArgs: definition-site order
341346
val formals = formalTypes(expr.tpe.paramTypes, typedArgs.length, removeByName = false, removeRepeated = false)
342347
// valDefs: call-site order

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,10 +3226,9 @@ trait Types extends api.Types { self: SymbolTable =>
32263226
sameLength(typeArgs, tp.typeArgs) && {
32273227
val lhs = if (isLowerBound) tp.typeArgs else typeArgs
32283228
val rhs = if (isLowerBound) typeArgs else tp.typeArgs
3229-
// this is a higher-kinded type var with same arity as tp.
3230-
// side effect: adds the type constructor itself as a bound
3231-
addBound(tp.typeConstructor)
3232-
isSubArgs(lhs, rhs, params, AnyDepth)
3229+
// This is a higher-kinded type var with same arity as tp.
3230+
// If so (see SI-7517), side effect: adds the type constructor itself as a bound.
3231+
isSubArgs(lhs, rhs, params, AnyDepth) && { addBound(tp.typeConstructor); true }
32333232
}
32343233
}
32353234
// The type with which we can successfully unify can be hidden

test/files/neg/t7509.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
t7509.scala:3: error: inferred type arguments [Int] do not conform to method crash's type parameter bounds [R <: AnyRef]
2+
crash(42)
3+
^
4+
t7509.scala:3: error: type mismatch;
5+
found : Int(42)
6+
required: R
7+
crash(42)
8+
^
9+
t7509.scala:3: error: could not find implicit value for parameter ev: R
10+
crash(42)
11+
^
12+
three errors found

test/files/neg/t7509.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object NMWE {
2+
def crash[R <: AnyRef](f: R)(implicit ev: R): Any = ???
3+
crash(42)
4+
}

test/files/pos/t7516/A_1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.reflect._,macros._, scala.language.experimental.macros
2+
3+
object A {
4+
def impl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
5+
val r = c.universe.reify { List(t.splice) }
6+
c.Expr[List[T]]( c.resetLocalAttrs(r.tree) )
7+
}
8+
def demo[T](t: T): List[T] = macro impl[T]
9+
}

test/files/pos/t7516/B_2.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object B {
2+
final case class CV(p: Int = 3, g: Int = 2)
3+
A.demo { val d = 4; CV(g = d); "a" }
4+
}

test/files/pos/t7517.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
trait Box[ K[A[x]] ]
2+
3+
object Box {
4+
// type constructor composition
5+
sealed trait [A[_], B[_]] { type l[T] = A[B[T]] }
6+
7+
// composes type constructors inside K
8+
type SplitBox[K[A[x]], B[x]] = Box[ ({ type l[A[x]] = K[ (A B)#l] })#l ]
9+
10+
def split[ K[A[x]], B[x] ](base: Box[K]): SplitBox[K,B] = ???
11+
12+
class Composed[B[_], L[A[x]] ] {
13+
val box: Box[L] = ???
14+
15+
type Split[ A[x] ] = L[ (A B)#l ]
16+
val a: Box[Split] = Box.split(box)
17+
18+
//Either of these work:
19+
val a1: Box[Split] = Box.split[L,B](box)
20+
val a2: Box[ ({ type l[A[x]] = L[ (A B)#l ] })#l ] = Box.split(box)
21+
}
22+
}

test/files/pos/t7532/A_1.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class R {
2+
public class attr { // Will have the bytecode name `R$attr`, not to be confused with `R@tr`!
3+
}
4+
public static class attr1 {
5+
}
6+
}

0 commit comments

Comments
 (0)