You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1009 B
39 lines
1009 B
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package codetoanalyze.java.nullsafe_default;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.view.View;
|
|
|
|
/**
|
|
* Test to ensure we have special messaging when misusing known nullable methods that have
|
|
* non-nullable alternatives.
|
|
*/
|
|
public class AlternativeRecommendations {
|
|
@SuppressLint("eradicate-field-not-initialized")
|
|
View field;
|
|
|
|
static void dereference_ShouldSuggestAlternative(View view) {
|
|
view.findViewById(2).setId(3);
|
|
}
|
|
|
|
static void passingParam_ShouldSuggestAlternative(View view) {
|
|
acceptsNonnullView(view.findViewById(2));
|
|
}
|
|
|
|
static View returnValue_ShouldSuggestAlternative(View view) {
|
|
return view.findViewById(2);
|
|
}
|
|
|
|
void assigningField_ShouldSuggestAlternative(View view) {
|
|
field = view.findViewById(2);
|
|
}
|
|
|
|
static void acceptsNonnullView(View view) {}
|
|
}
|