From a924fd0e7e5da7fef12227b503e5eecd231a5abd Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 3 Mar 2015 11:32:18 +0100 Subject: [PATCH 1/4] Fixed: Generate compiler error when ivar is already declared in superclass --- Objective-J/ObjJAcornCompiler.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index 0e9d16f98..d5561fb47 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -1754,8 +1754,15 @@ ClassDeclarationStatement: function(node, st, c) { ivar = {"type": ivarType, "name": ivarName}, accessors = ivarDecl.accessors; - if (ivars[ivarName]) - throw compiler.error_message("Instance variable '" + ivarName + "' is already declared for class " + className, ivarDecl.id); + var checkIfIvarIsAlreadyDeclaredAndInSuperClass = function(aClassDef, recursiveFunction) { + if (aClassDef.ivars[ivarName]) + throw compiler.error_message("Instance variable '" + ivarName + "' is already declared for class " + className + (aClassDef.name !== className ? " in superclass " + aClassDef.name : ""), ivarDecl.id); + if (aClassDef.superClass) + recursiveFunction(aClassDef.superClass, recursiveFunction); + } + + // Check if ivar is already declared in this class or its super classes. + checkIfIvarIsAlreadyDeclaredAndInSuperClass(classDef, checkIfIvarIsAlreadyDeclaredAndInSuperClass); var isTypeDefined = !ivarTypeIsClass || typeof global[ivarType] !== "undefined" || typeof window[ivarType] !== "undefined" || compiler.getClassDef(ivarType) || compiler.getTypeDef(ivarType) || ivarType == classDef.name; From b47ad50d420fcbd69cbaff8770b9e773cc3f802f Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 3 Mar 2015 11:33:20 +0100 Subject: [PATCH 2/4] Fixed: Made the compiler manual test cases work again --- Tests/Manual/CompilationTests/TestCases/7.j | 2 +- Tests/Manual/CompilationTests/run.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Manual/CompilationTests/TestCases/7.j b/Tests/Manual/CompilationTests/TestCases/7.j index cdff5aeda..a2202e387 100644 --- a/Tests/Manual/CompilationTests/TestCases/7.j +++ b/Tests/Manual/CompilationTests/TestCases/7.j @@ -7,7 +7,7 @@ Error on line 10001 of file [unknown] SyntaxError: @implementation MyType : CPObject ^ -ERROR line 5 in file:[__PATH__]: MyType is already declared as type +ERROR line 5 in file:[__PATH__]: MyType is already declared as a type END_EXPECTED */ diff --git a/Tests/Manual/CompilationTests/run.py b/Tests/Manual/CompilationTests/run.py index e21eebaa3..b827faa8b 100755 --- a/Tests/Manual/CompilationTests/run.py +++ b/Tests/Manual/CompilationTests/run.py @@ -55,6 +55,7 @@ def cleanup_output(output): output = output.replace(" ", "") output = output.replace("\n", "") output = output.replace("[0m", "") + output = re.sub('\d*offile\[unknown\]', '', output) return re.sub('[^\s!-~]', '', output) From 1d1aae03f37926723611d600aa3fe0e571039bf2 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 3 Mar 2015 11:33:50 +0100 Subject: [PATCH 3/4] Added: Test case for duplicate ivar in superclass --- Tests/Manual/CompilationTests/TestCases/11.j | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Tests/Manual/CompilationTests/TestCases/11.j diff --git a/Tests/Manual/CompilationTests/TestCases/11.j b/Tests/Manual/CompilationTests/TestCases/11.j new file mode 100644 index 000000000..c7900c4d9 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/11.j @@ -0,0 +1,28 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10778 of file [unknown] +SyntaxError: +int myIvar; + ^ +ERROR line 12 in file:[__PATH__]: Instance variable 'myIvar' is already declared for class MySubclass in superclass MySuperclass +END_EXPECTED +*/ + +@import + +@implementation MySuperclass : CPObject +{ + int myIvar; +} + +@end + +@implementation MySubclass : MySuperclass +{ + int myIvar; +} + +@end \ No newline at end of file From 03a6e6fc6aeb1e9485cf831194bd70a702d890d6 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 3 Mar 2015 11:34:49 +0100 Subject: [PATCH 4/4] Fixed: Removed ivars that are already declared in superclass --- AppKit/CPColorPanel.j | 1 - AppKit/CPMenu/_CPMenuBarWindow.j | 1 - AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j | 1 - AppKit/CPWindow/_CPHUDWindowView.j | 1 - AppKit/CPWindow/_CPStandardWindowView.j | 1 - AppKit/Cib/CPCibHelpConnector.j | 1 - AppKit/_CPPopoverWindow.j | 1 - Tools/nib2cib/NSButton.j | 1 - Tools/nib2cib/NSDatePicker.j | 1 - 9 files changed, 9 deletions(-) diff --git a/AppKit/CPColorPanel.j b/AppKit/CPColorPanel.j index 7d847a30f..d00baa311 100644 --- a/AppKit/CPColorPanel.j +++ b/AppKit/CPColorPanel.j @@ -71,7 +71,6 @@ var SharedColorPanel = nil, */ @implementation CPColorPanel : CPPanel { - _CPColorPanelToolbar _toolbar; _CPColorPanelSwatches _swatchView; _CPColorPanelPreview _previewView; diff --git a/AppKit/CPMenu/_CPMenuBarWindow.j b/AppKit/CPMenu/_CPMenuBarWindow.j index db9077b06..693cafaea 100644 --- a/AppKit/CPMenu/_CPMenuBarWindow.j +++ b/AppKit/CPMenu/_CPMenuBarWindow.j @@ -32,7 +32,6 @@ @implementation _CPMenuBarWindow : CPPanel { - CPMenu _menu; CPView _highlightView; CPArray _menuItemViews; diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j index 2cec0efae..329ee3899 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j @@ -29,7 +29,6 @@ CGRect _animationTargetRect @accessors(property=_animationTargetRect); BOOL _selected @accessors(getter=_isSelected, setter=_setSelected:); BOOL _lastSelected @accessors(getter=_isLastSelected, setter=_setLastSelected:); - CPColor _backgroundColor @accessors(property=backgroundColor); BOOL _editable @accessors(getter=isEditable, setter=setEditable:); } diff --git a/AppKit/CPWindow/_CPHUDWindowView.j b/AppKit/CPWindow/_CPHUDWindowView.j index 829f78eee..9103eb562 100644 --- a/AppKit/CPWindow/_CPHUDWindowView.j +++ b/AppKit/CPWindow/_CPHUDWindowView.j @@ -27,7 +27,6 @@ @implementation _CPHUDWindowView : _CPTitleableWindowView { - CPView _toolbarView; CPButton _closeButton; } diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index d8ea56ceb..dea5937be 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -94,7 +94,6 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; _CPTexturedWindowHeadView _headView; CPView _dividerView; CPView _bodyView; - CPView _toolbarView; CPButton _closeButton; CPButton _minimizeButton; diff --git a/AppKit/Cib/CPCibHelpConnector.j b/AppKit/Cib/CPCibHelpConnector.j index 925b3393f..3748e757e 100644 --- a/AppKit/Cib/CPCibHelpConnector.j +++ b/AppKit/Cib/CPCibHelpConnector.j @@ -24,7 +24,6 @@ @implementation CPCibHelpConnector : CPCibConnector { - id _destination; id _file; id _marker; } diff --git a/AppKit/_CPPopoverWindow.j b/AppKit/_CPPopoverWindow.j index e836fea73..7a1f5edcc 100644 --- a/AppKit/_CPPopoverWindow.j +++ b/AppKit/_CPPopoverWindow.j @@ -63,7 +63,6 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, BOOL _browserAnimates; BOOL _isObservingFrame; BOOL _shouldPerformAnimation; - CPInteger _implementedDelegateMethods; CGRect _targetRect; CPWindow _targetWindow; JSObject _orderOutTransitionFunction; diff --git a/Tools/nib2cib/NSButton.j b/Tools/nib2cib/NSButton.j index 4517263fa..2a5aa1d08 100644 --- a/Tools/nib2cib/NSButton.j +++ b/Tools/nib2cib/NSButton.j @@ -409,7 +409,6 @@ var NSButtonIsBorderedMask = 0x00800000, @implementation NSButtonCell : NSActionCell { - BOOL _isBordered @accessors(readonly, getter=isBordered); int _bezelStyle @accessors(readonly, getter=bezelStyle); CPString _title @accessors(readonly, getter=title); diff --git a/Tools/nib2cib/NSDatePicker.j b/Tools/nib2cib/NSDatePicker.j index a90983ec5..c14ab8c55 100644 --- a/Tools/nib2cib/NSDatePicker.j +++ b/Tools/nib2cib/NSDatePicker.j @@ -177,7 +177,6 @@ var NSDatePickerDefaultSize = 22, BOOL _drawsBackground @accessors(getter=drawsBackground); CPDate _minDate @accessors(getter=minDate); CPDate _maxDate @accessors(getter=maxDate); - CPDateFormatter _formatter @accessors(getter=formatter); CPInteger _datePickerMode @accessors(getter=datePickerMode); CPInteger _datePickerElements @accessors(getter=datePickerElements); CPInteger _datePickerType @accessors(getter=datePickerType);