File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -1716,6 +1716,19 @@ object Types {
1716
1716
else funType
1717
1717
}
1718
1718
1719
+ final def dropJavaMethod (using Context ): Type = this match
1720
+ case pt : PolyType => pt.derivedLambdaType(resType = pt.resType.dropJavaMethod)
1721
+
1722
+ case mt : MethodType =>
1723
+ if mt.isJavaMethod then
1724
+ MethodType .apply(mt.paramNames, mt.paramInfos, mt.resType.dropJavaMethod)
1725
+ else
1726
+ mt.derivedLambdaType(resType = mt.resType.dropJavaMethod)
1727
+
1728
+ case _ => this
1729
+
1730
+ end dropJavaMethod
1731
+
1719
1732
/** The signature of this type. This is by default NotAMethod,
1720
1733
* but is overridden for PolyTypes, MethodTypes, and TermRef types.
1721
1734
* (the reason why we deviate from the "final-method-with-pattern-match-in-base-class"
Original file line number Diff line number Diff line change @@ -111,15 +111,8 @@ object ErrorReporting {
111
111
112
112
/** A subtype log explaining why `found` does not conform to `expected` */
113
113
def whyNoMatchStr (found : Type , expected : Type ): String = {
114
- def dropJavaMethod (tp : Type ): Type = tp match {
115
- case tp : PolyType =>
116
- tp.derivedLambdaType(resType = dropJavaMethod(tp.resultType))
117
- case tp : MethodType if tp.isJavaMethod =>
118
- MethodType (tp.paramNames, tp.paramInfos, dropJavaMethod(tp.resultType))
119
- case tp => tp
120
- }
121
- val found1 = dropJavaMethod(found)
122
- val expected1 = dropJavaMethod(expected)
114
+ val found1 = found.dropJavaMethod
115
+ val expected1 = expected.dropJavaMethod
123
116
if ((found1 eq found) != (expected eq expected1) && (found1 <:< expected1))
124
117
i """
125
118
|(Note that Scala's and Java's representation of this type differs) """
Original file line number Diff line number Diff line change @@ -1024,7 +1024,7 @@ class Namer { typer: Typer =>
1024
1024
if sym.isStableMember && sym.isPublic && ! refersToPrivate(path.tpe) then
1025
1025
(StableRealizable , ExprType (path.tpe.select(sym)))
1026
1026
else
1027
- (EmptyFlags , mbr.info.ensureMethodic)
1027
+ (EmptyFlags , mbr.info.ensureMethodic.dropJavaMethod )
1028
1028
var mbrFlags = Exported | Method | Final | maybeStable | sym.flags & RetainedExportFlags
1029
1029
if sym.is(ExtensionMethod ) then mbrFlags |= ExtensionMethod
1030
1030
val forwarderName = checkNoConflict(alias, isPrivate = false , span)
Original file line number Diff line number Diff line change
1
+ import java .util .Arrays ;
2
+
3
+ public class JavaExporter_1 {
4
+ public static String varargExample (String ... args ) {
5
+ return Arrays .toString (args );
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ object Exporter :
2
+ export JavaExporter_1 ._
3
+
4
+ import Exporter ._
5
+
6
+ @ main def Test =
7
+ println(varargExample(" a" , " b" , " c" ))
You can’t perform that action at this time.
0 commit comments