@@ -285,15 +285,12 @@ protected boolean needsStripping() {
285
285
@ Override
286
286
public Type visitMethodType (MethodType t , S s ) {
287
287
List <Type > argtypes = t .argtypes ;
288
- List <Type > bindingtypes = t .bindingtypes ;
289
288
Type restype = t .restype ;
290
289
List <Type > thrown = t .thrown ;
291
- List <Type > bindingtypes1 = bindingtypes != null ? visit (bindingtypes , s ) : null ;
292
290
List <Type > argtypes1 = visit (argtypes , s );
293
291
Type restype1 = visit (restype , s );
294
292
List <Type > thrown1 = visit (thrown , s );
295
293
if (argtypes1 == argtypes &&
296
- bindingtypes1 == bindingtypes &&
297
294
restype1 == restype &&
298
295
thrown1 == thrown ) return t ;
299
296
else {
@@ -303,7 +300,6 @@ protected boolean needsStripping() {
303
300
return true ;
304
301
}
305
302
};
306
- methodType .bindingtypes = bindingtypes1 ;
307
303
return methodType ;
308
304
}
309
305
}
@@ -312,6 +308,22 @@ protected boolean needsStripping() {
312
308
public Type visitForAll (ForAll t , S s ) {
313
309
return visit (t .qtype , s );
314
310
}
311
+
312
+ @ Override
313
+ public Type visitPatternType (PatternType t , S s ) {
314
+ List <Type > bindingtypes = t .bindingtypes ;
315
+ List <Type > bindingtypes1 = visit (bindingtypes , s );
316
+ if (bindingtypes1 == bindingtypes ) return t ;
317
+ else {
318
+ PatternType patternType = new PatternType (bindingtypes1 , /*XXX*/ t .restype , t .tsym ) {
319
+ @ Override
320
+ protected boolean needsStripping () {
321
+ return true ;
322
+ }
323
+ };
324
+ return patternType ;
325
+ }
326
+ }
315
327
}
316
328
317
329
/** map a type function over all immediate descendants of this type
@@ -722,6 +734,8 @@ public static List<Type> filter(List<Type> ts, Predicate<Type> tf) {
722
734
*/
723
735
public MethodType asMethodType () { throw new AssertionError (); }
724
736
737
+ public PatternType asPatternType () { throw new AssertionError (); }
738
+
725
739
/** Complete loading all classes in this type.
726
740
*/
727
741
public void complete () {}
@@ -1479,7 +1493,6 @@ public <R, P> R accept(TypeVisitor<R, P> v, P p) {
1479
1493
public static class MethodType extends Type implements ExecutableType , LoadableConstant {
1480
1494
1481
1495
public List <Type > argtypes ;
1482
- public List <Type > bindingtypes ;
1483
1496
public Type restype ;
1484
1497
public List <Type > thrown ;
1485
1498
@@ -1528,7 +1541,7 @@ public String toString() {
1528
1541
public List <Type > getParameterTypes () { return argtypes ; }
1529
1542
1530
1543
@ DefinedBy (Api .LANGUAGE_MODEL )
1531
- public List <Type > getBindingTypes () { return bindingtypes ; }
1544
+ public List <Type > getBindingTypes () { return List . nil () ; }
1532
1545
1533
1546
@ DefinedBy (Api .LANGUAGE_MODEL )
1534
1547
public Type getReturnType () { return restype ; }
@@ -1542,7 +1555,6 @@ public Type getReceiverType() {
1542
1555
public boolean isErroneous () {
1543
1556
return
1544
1557
isErroneous (argtypes ) ||
1545
- bindingtypes != null && isErroneous (bindingtypes ) ||
1546
1558
restype != null && restype .isErroneous ();
1547
1559
}
1548
1560
@@ -1560,8 +1572,6 @@ public boolean contains(Type elem) {
1560
1572
public void complete () {
1561
1573
for (List <Type > l = argtypes ; l .nonEmpty (); l = l .tail )
1562
1574
l .head .complete ();
1563
- for (List <Type > l = bindingtypes ; l .nonEmpty (); l = l .tail )
1564
- l .head .complete ();
1565
1575
restype .complete ();
1566
1576
recvtype .complete ();
1567
1577
for (List <Type > l = thrown ; l .nonEmpty (); l = l .tail )
@@ -1923,6 +1933,99 @@ public <R, P> R accept(TypeVisitor<R, P> v, P p) {
1923
1933
}
1924
1934
}
1925
1935
1936
+ public static class PatternType extends Type implements ExecutableType {
1937
+ public List <Type > bindingtypes ;
1938
+ public Type restype ;
1939
+
1940
+ public PatternType (List <Type > bindingtypes ,
1941
+ Type restype , //TODO:
1942
+ TypeSymbol methodClass ) {
1943
+ super (methodClass , List .nil ());
1944
+ this .bindingtypes = bindingtypes ;
1945
+ this .restype = restype ;
1946
+ }
1947
+
1948
+ @ Override
1949
+ public TypeTag getTag () {
1950
+ return TypeTag .PATTERN ;
1951
+ }
1952
+
1953
+ public <R ,S > R accept (Type .Visitor <R ,S > v , S s ) {
1954
+ return v .visitPatternType (this , s );
1955
+ }
1956
+
1957
+ /** The Java source which this type represents.
1958
+ *
1959
+ * XXX 06/09/99 iris This isn't correct Java syntax, but it probably
1960
+ * should be.
1961
+ */
1962
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1963
+ public String toString () {
1964
+ StringBuilder sb = new StringBuilder ();
1965
+ appendAnnotationsString (sb );
1966
+ sb .append ("(out" );
1967
+ sb .append (bindingtypes );
1968
+ sb .append (')' );
1969
+ return sb .toString ();
1970
+ }
1971
+
1972
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1973
+ public List <Type > getParameterTypes () { return List .nil (); }
1974
+
1975
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1976
+ public List <Type > getBindingTypes () { return bindingtypes ; }
1977
+
1978
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1979
+ public Type getReturnType () { return restype ; }
1980
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1981
+ public Type getReceiverType () {
1982
+ return Type .noType ;
1983
+ }
1984
+ @ DefinedBy (Api .LANGUAGE_MODEL )
1985
+ public List <Type > getThrownTypes () { return List .nil (); }
1986
+
1987
+ @ Override
1988
+ public PatternType asPatternType () { return this ; }
1989
+
1990
+ public boolean isErroneous () {
1991
+ return
1992
+ bindingtypes != null && isErroneous (bindingtypes );
1993
+ }
1994
+
1995
+ @ Override
1996
+ public int poolTag () {
1997
+ return ClassFile .CONSTANT_MethodType ; //TODO
1998
+ }
1999
+
2000
+ public boolean contains (Type elem ) {
2001
+ return elem .equalsIgnoreMetadata (this );
2002
+ }
2003
+
2004
+ public void complete () {
2005
+ for (List <Type > l = bindingtypes ; l .nonEmpty (); l = l .tail )
2006
+ l .head .complete ();
2007
+ }
2008
+
2009
+ @ DefinedBy (Api .LANGUAGE_MODEL )
2010
+ public List <TypeVar > getTypeVariables () {
2011
+ return List .nil ();
2012
+ }
2013
+
2014
+ public TypeSymbol asElement () {
2015
+ return null ;
2016
+ }
2017
+
2018
+ @ DefinedBy (Api .LANGUAGE_MODEL )
2019
+ public TypeKind getKind () {
2020
+ return TypeKind .EXECUTABLE ;
2021
+ }
2022
+
2023
+ @ DefinedBy (Api .LANGUAGE_MODEL )
2024
+ public <R , P > R accept (TypeVisitor <R , P > v , P p ) {
2025
+ return v .visitExecutable (this , p );
2026
+ }
2027
+ }
2028
+
1926
2029
/** A class for inference variables, for use during method/diamond type
1927
2030
* inference. An inference variable has upper/lower bounds and a set
1928
2031
* of equality constraints. Such bounds are set during subtyping, type-containment,
@@ -2444,6 +2547,7 @@ public interface Visitor<R,S> {
2444
2547
R visitWildcardType (WildcardType t , S s );
2445
2548
R visitArrayType (ArrayType t , S s );
2446
2549
R visitMethodType (MethodType t , S s );
2550
+ R visitPatternType (PatternType t , S s );
2447
2551
R visitPackageType (PackageType t , S s );
2448
2552
R visitModuleType (ModuleType t , S s );
2449
2553
R visitTypeVar (TypeVar t , S s );
0 commit comments