File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -497,9 +497,15 @@ object ProtoTypes {
497
497
if wideFormal eq formal then targ1
498
498
else targ1.tpe match
499
499
case tp : AppliedType if tp.hasCaptureConversionArg =>
500
- errorTree(targ1,
501
- em """ argument for by-name parameter contains capture conversion skolem types:
502
- | $tp""" )
500
+ stripCast(targ1).tpe match
501
+ case tp : AppliedType if tp.hasWildcardArg =>
502
+ errorTree(targ1,
503
+ em """ argument for by-name parameter is not a value
504
+ |and contains wildcard arguments: $tp
505
+ |
506
+ |Assign it to a val and pass that instead.
507
+ | """ )
508
+ case _ => targ1
503
509
case _ => targ1
504
510
}
505
511
Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ object Main:
14
14
def onestep [T ](m : () => Magic [T ]): String = m().step(m().init)
15
15
def unostep [T ](m : => Magic [T ]): String = m.step(m.init)
16
16
17
- val iter : Iterator [Magic [? ]] = Iterator ( IntMagic , StrMagic )
17
+ val iter : Iterator [Magic [? ]] = Iterator .tabulate( Int . MaxValue )(i => if i % 2 == 0 then IntMagic else StrMagic )
18
18
19
19
// was: class java.lang.String cannot be cast to class java.lang.Integer
20
20
def main (args : Array [String ]): Unit =
21
21
onestep(() => iter.next()) // error
22
22
unostep(iter.next()) // error
23
+ val m = iter.next()
24
+ unostep(m) // ok, because m is a value
Original file line number Diff line number Diff line change
1
+ // from failure in the community project
2
+ // jackson-module-scala
3
+ // in ScalaAnnotationIntrospectorModule.scala:139:12
4
+
5
+ import scala .language .implicitConversions
6
+
7
+ trait EnrichedType [X ]:
8
+ def value : X
9
+
10
+ trait ClassW extends EnrichedType [Class [_]]:
11
+ def extendsScalaClass = false
12
+
13
+ class Test :
14
+ implicit def mkClassW (c : => Class [_]): ClassW = new ClassW :
15
+ lazy val value = c
16
+
17
+ def test1 (c1 : Class [_]) = c1.extendsScalaClass // ok: c1 is a value
18
+ def test2 (c2 : Class [_]) = mkClassW(c2).extendsScalaClass // ok: c2 is a value
19
+ // c1 in test1 goes throw adapting to find the extension method and gains the wildcard capture cast then
20
+ // c2 in test2 goes straight to typedArg, as it's already an arg, so it never gets wildcard captured
You can’t perform that action at this time.
0 commit comments