File tree 1 file changed +12
-1
lines changed
src/main/java/se/kth/spork/cli
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 10
10
import spoon .reflect .visitor .DefaultJavaPrettyPrinter ;
11
11
import spoon .reflect .visitor .DefaultTokenWriter ;
12
12
import spoon .reflect .visitor .PrinterHelper ;
13
+ import spoon .reflect .visitor .PrintingContext ;
13
14
14
15
import java .io .IOException ;
15
16
import java .io .RandomAccessFile ;
@@ -65,7 +66,17 @@ public SporkPrettyPrinter scan(CtElement e) {
65
66
if (structuralConflict != null ) {
66
67
writeStructuralConflict (structuralConflict );
67
68
} else {
68
- super .scan (e );
69
+ if (getContext ().forceWildcardGenerics ()) {
70
+ // Forcing wildcard generics can cause crashes when references can't be resolved, so we don't want
71
+ // to do it. An example of where this sometimes causes crashes is if a nested class is used in an
72
+ // instanceof check.
73
+ try (PrintingContext .Writable _context = getContext ().modify ()) {
74
+ _context .forceWildcardGenerics (false );
75
+ super .scan (e );
76
+ }
77
+ } else {
78
+ super .scan (e );
79
+ }
69
80
}
70
81
71
82
return this ;
You can’t perform that action at this time.
0 commit comments