mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
allow object types to be inner classes
This commit is contained in:
parent
f83e8462cd
commit
efe74a329c
@ -483,6 +483,10 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitClassDef(JCClassDecl classdecl) {
|
public void visitClassDef(JCClassDecl classdecl) {
|
||||||
|
if(Util.hasAnnotationType(classdecl.type.tsym, JSweetConfig.ANNOTATION_OBJECT_TYPE)) {
|
||||||
|
// object types are ignored
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (getParent() instanceof JCClassDecl) {
|
if (getParent() instanceof JCClassDecl) {
|
||||||
report(classdecl, JSweetProblem.INNER_CLASS, classdecl.name);
|
report(classdecl, JSweetProblem.INNER_CLASS, classdecl.name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import source.structural.NameClashes;
|
|||||||
import source.structural.NameClashesWithMethodInvocations;
|
import source.structural.NameClashesWithMethodInvocations;
|
||||||
import source.structural.NoInstanceofForInterfaces;
|
import source.structural.NoInstanceofForInterfaces;
|
||||||
import source.structural.NoWildcardsInImports;
|
import source.structural.NoWildcardsInImports;
|
||||||
|
import source.structural.ObjectTypes;
|
||||||
import source.structural.TwoClassesInSameFile;
|
import source.structural.TwoClassesInSameFile;
|
||||||
import source.structural.WrongConstructsInEnums;
|
import source.structural.WrongConstructsInEnums;
|
||||||
import source.structural.WrongConstructsInInterfaces;
|
import source.structural.WrongConstructsInInterfaces;
|
||||||
@ -239,4 +240,11 @@ public class StructuralTests extends AbstractTest {
|
|||||||
} , getSourceFile(source.structural.wrongglobals.Globals.class));
|
} , getSourceFile(source.structural.wrongglobals.Globals.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObjectTypes() {
|
||||||
|
transpile(logHandler -> {
|
||||||
|
logHandler.assertReportedProblems();
|
||||||
|
} , getSourceFile(ObjectTypes.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/test/java/source/structural/ObjectTypes.java
Normal file
32
src/test/java/source/structural/ObjectTypes.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* JSweet - http://www.jsweet.org
|
||||||
|
* Copyright (C) 2015 CINCHEO SAS <renaud.pawlak@cincheo.fr>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package source.structural;
|
||||||
|
|
||||||
|
import jsweet.lang.ObjectType;
|
||||||
|
|
||||||
|
public class ObjectTypes {
|
||||||
|
@ObjectType
|
||||||
|
public static class Indexed {
|
||||||
|
int index;
|
||||||
|
}
|
||||||
|
public static void m(Indexed param) {}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
m(new Indexed() {{ index = 2; }});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user