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 {
17161716 else funType
17171717 }
17181718
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+
17191732 /** The signature of this type. This is by default NotAMethod,
17201733 * but is overridden for PolyTypes, MethodTypes, and TermRef types.
17211734 * (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 {
111111
112112 /** A subtype log explaining why `found` does not conform to `expected` */
113113 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
123116 if ((found1 eq found) != (expected eq expected1) && (found1 <:< expected1))
124117 i """
125118 |(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 =>
10241024 if sym.isStableMember && sym.isPublic && ! refersToPrivate(path.tpe) then
10251025 (StableRealizable , ExprType (path.tpe.select(sym)))
10261026 else
1027- (EmptyFlags , mbr.info.ensureMethodic)
1027+ (EmptyFlags , mbr.info.ensureMethodic.dropJavaMethod )
10281028 var mbrFlags = Exported | Method | Final | maybeStable | sym.flags & RetainedExportFlags
10291029 if sym.is(ExtensionMethod ) then mbrFlags |= ExtensionMethod
10301030 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